from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
import shutil
import os
class RightWidget(QWidget):
    def __init__(self):
        super().__init__()
        #设置布局
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        self.layout.setContentsMargins(5,0,5,0)
        self.layout.setSpacing(0)
        #设置顶部组件
        self.top_bar_widget = QWidget(self)
        self.top_bar_widget.setFixedHeight(43)
        self.pic = QPixmap("static/bingtu.jpg")
        self.pic = self.pic.scaled(41,43)
        self.lab_pic = QLabel(self.top_bar_widget)
        self.lab_pic.setPixmap(self.pic)
        self.lab1 = QLabel("结果查询",self.top_bar_widget)
        self.lab1.move(50,8)
        font = QFont("PingFang SC Regular")
        font.setPixelSize(18)
        self.lab1.setFont(font)
        #设置主体组件
        self.widget = QWidget(self)
        self.widget.layout = QHBoxLayout()
        self.widget.setLayout(self.widget.layout)
        self.stu = TemplatesStu()
        self.score = TemplatesScore()
        self.result = TemplatesResult()
        self.widget.layout.addWidget(self.stu)
        self.widget.layout.addWidget(self.score)
        self.widget.layout.addWidget(self.result)
        #在布局中添加组件
        self.layout.addWidget(self.top_bar_widget)
        self.layout.addWidget(self.widget)
class TemplatesStu(QWidget):
    def __init__(self,parent=None):
        super().__init__(parent=parent)
        pal = QPalette(self.palette())
        pal.setColor(QPalette.Background,QColor(255,255,255))
        self.setAutoFillBackground(True)
        self.setPalette(pal)
        self.resize(175,305)
        self.pic = QPixmap("static/excel.jpg")
        self.pic = self.pic.scaled(30, 34, Qt.KeepAspectRatio)
        self.lab1 = QLabel(self)
        self.lab1.move(5,5)
        self.lab1.setPixmap(self.pic)
        self.lab2 = QLabel(self)
        self.lab2.setText("权重录入")
        font = QFont("PingFang SC Regular")
        font.setPixelSize(18)
        self.lab2.setFont(font)
        self.lab2.move(45,30)
        self.btn1 = QPushButton("导出模版",self)
        self.btn2 = QPushButton("导入权重",self)
        self.btn1.move(10,245)
        self.btn1.setFixedWidth(75)
        self.btn2.move(90,245)
        self.btn2.setFixedWidth(75)
        self.btn1.clicked.connect(self.export_templates)
        self.btn2.clicked.connect(self.import_weight)
    def export_templates(self):
        export_file = QFileDialog.getSaveFileName(self,"课程与指标对应关系",filter="excel(*.xlsx)")
        file_path = export_file[0]
        if file_path!="":
            shutil.copyfile(os.path.join(os.getcwd(),"static/excel/模板_课程与指标对应关系.xlsx"),file_path)
            QMessageBox.information(self,'导出成功','导出成功',QMessageBox.Yes)
    def import_weight(self):
        export_file = QFileDialog.getOpenFileName(self,"导入权重",filter="excel(*.xlsx)")
        file_path = export_file[0]
        if file_path!="":
            shutil.copyfile(file_path,os.path.join(os.getcwd(),"tmp/课程与指标对应关系.xlsx"))
class TemplatesScore(QWidget):
    def __init__(self,parent=None):
        super().__init__(parent=parent)
        pal = QPalette(self.palette())
        pal.setColor(QPalette.Background,QColor(255,255,255))
        self.setAutoFillBackground(True)
        self.setPalette(pal)
        self.resize(175,305)
        self.pic = QPixmap("static/students.jpg")
        self.pic = self.pic.scaled(30, 40)
        self.lab1 = QLabel(self)
        self.lab1.move(5,5)
        self.lab1.setPixmap(self.pic)
        self.lab2 = QLabel(self)
        self.lab2.setText("查询学生\n详细信息")
        tmp = QFont("PingFang SC Regular",18)
        tmp.setPixelSize(18)
        self.lab2.setFont(tmp)
        self.lab2.move(45,20)
        self.lab3 = QLabel(self)
        self.lab3.setText("姓名")
        f3 = QFont("PingFang SC Regular",16)
        f3.setPixelSize(16)
        self.lab3.setFont(f3)
        self.lab3.move(10,100)
        self.lab4 = QLabel(self)
        self.name_line = QLineEdit(self)
        self.code_line = QLineEdit(self)
        self.name_line.move(50,100)
        self.code_line.move(50,140)
        self.name_line.setFixedWidth(100)
        self.code_line.setFixedWidth(100)
        self.lab4.setText("学号")
        f4 = QFont("PingFang SC Regular",16)
        f4.setPixelSize(16)
        self.lab4.setFont(f4)
        self.lab4.move(10,140)
        self.btn1 = QPushButton("预览毕业目标完成情况",self)
        self.btn2 = QPushButton("导出各科成绩表",self)
        self.btn1.move(0,190)
        self.btn2.move(20,245)
        

class TemplatesResult(QWidget):
    def __init__(self,parent=None):
        super().__init__(parent=parent)
        pal = QPalette(self.palette())
        pal.setColor(QPalette.Background,QColor(255,255,255))
        self.setAutoFillBackground(True)
        self.setPalette(pal)
        self.resize(175,305)
        self.pic = QPixmap("static/phd.jpg")
        self.pic = self.pic.scaled(37, 33, Qt.KeepAspectRatio)
        self.lab1 = QLabel(self)
        self.lab1.move(5,5)
        self.lab1.setPixmap(self.pic)
        self.lab2 = QLabel(self)
        self.lab2.setText("查询班级/年级")
        self.lab3 = QLabel(self)
        self.lab3.setText("年级")
        font = QFont("PingFang SC Regular")
        font.setPixelSize(16)
        self.lab3.setFont(font)
        self.lab3.move(15,100)
        tmp = QFont("PingFang SC Regular")
        tmp.setPixelSize(18)
        self.lab2.setFont(tmp)
        self.lab2.move(35,30)
        self.box1 = QCheckBox("班级",self)
        self.box2 = QCheckBox("只看不合格学生",self)
        self.box3 = QCheckBox("包含留学生",self)
        self.box1.move(15,130)
        self.box2.move(15,160)
        self.box3.move(15,190)
        self.box1.setFont(font)
        self.box2.setFont(font)
        self.box3.setFont(font)
        self.btn1 = QPushButton("导出完成情况表",self)
        self.btn1.setFixedWidth(70)
        self.line1 = QLineEdit(self)
        self.line1.setFixedWidth(100)
        self.line1.move(55,100)
        self.line2 = QLineEdit(self)
        self.line2.move(70,130)
        self.line2.setFixedWidth(85)
        self.btn1.move(15,240)
        self.btn1.setFixedWidth(150)
if __name__=="__main__":
    app = QApplication(sys.argv)
    window = RightWidget()
    window.show()
    sys.exit(app.exec_())